package com.caregiver.watch.business.notice.controller;

import com.caregiver.watch.business.notice.model.dto.BindPushIdParam;
import com.caregiver.watch.business.notice.model.dto.UnbindPushIdParam;
import com.caregiver.watch.business.notice.service.PushService;
import com.caregiver.watch.business.notice.vo.SystemNoticeVo;
import com.caregiver.watch.business.notice.service.NoticeService;
import com.caregiver.watch.common.domain.R;
import com.github.pagehelper.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: caregiver-watch
 * @author: 疆戟
 * @create: 2025-10-04 09:42
 */
@Tag(name  = "SystemController", description = "系统")
@RestController
@RequestMapping("notice")
public class NoticeController {

    @Autowired
    private NoticeService noticeService;
    @Autowired
    private PushService pushService;

    // 绑定通知ID
    @Operation(summary = "绑定极光推送ID(用户登录后需要绑定用户ID和极光推送ID的关联关系)")
    @PostMapping("bindPushId")
    public R<Boolean> bindPushId(BindPushIdParam param) {
        return R.ok(pushService.bindPushId(param));
    }

    @Operation(summary = "解绑极光推送ID(用户退出登录后解绑)")
    @PostMapping("unbindPushId")
    public R<Boolean> unbindPushId(@RequestBody UnbindPushIdParam param) {
        return R.ok(pushService.unbindPushId(param));
    }

    // 获取系统通知列表
    @Operation(summary = "获取系统通知列表")
    @GetMapping("queryNoticeList")
    public R<Page<SystemNoticeVo>> queryNoticeList() {
        return R.ok(noticeService.queryNoticeList());
    }


    @Operation(summary = "获取系统通知详情")
    @GetMapping("queryNoticeDetail")
    public R<SystemNoticeVo> queryNoticeDetail(@RequestParam("noticeId") Long noticeId) {
        return R.ok(noticeService.queryNoticeDetail(noticeId));
    }
}
